You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: only preventDefault on cancelable touchmove events - #539
The window touchmove listener in useTouchEvent now calls preventDefault() only when e.cancelable is true.
Why
The preview opens while a touch-scroll gesture is sometimes still in progress. The remaining touchmove events in that gesture are not cancelable, so Chrome ignores preventDefault() and logs one intervention per event:
[Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted.
Behaviour is unchanged: a non-cancelable event can't be prevented, and cancelable events are still blocked from scrolling the page.
Tests
New cases in tests/previewTouch.test.tsx
Manual check: Chrome DevTools device emulation and real Android device
This change stops Chrome's "Ignored attempt to cancel a touchmove" warnings by calling preventDefault only on cancelable events. Scrolling is still blocked for cancelable events. No merge-blocking risk is evident.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
标题“fix: only preventDefault on cancelable touchmove events”准确描述了主要变更:全局 touchmove 监听器现在仅在 e.cancelable 为 true 时调用 preventDefault()。这与原始摘要和 PR 目标一致,目标是消除 Chrome 对不可取消事件的 “Ignored attempt to cancel a to…
Linked Issues check
关联问题 [#538] 的核心要求是避免在不可取消的 touchmove 事件上调用 preventDefault(),从而消除 Chrome 的 "Ignored attempt to cancel a touchmove event" 警告。reviewed head 的 src/hooks/useTouchEvent.ts 中,window touchmove 监听函数 preventDef…
变更范围仅限于 src/hooks/useTouchEvent.ts 的 touchmove 监听守卫和 tests/previewTouch.test.tsx 中对应的测试。守卫修改直接实现 [#538] 的要求。摘要还提到在 onTouchEnd 中移除了 @typescript-eslint/no-shadow 禁用注释。该改动属于同一文件的小范围清理,与 touchmove 行为修改处于同一 hook 内,未改变 onTouchEnd 的逻辑。未发现与 issue 无关的功能变更。本次未能读取 base 与 head 之间的文本 diff(changed blobs 缺失),因此上述判断基于 head 文件内容和摘要。
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
ESLint install timed out. The project may have too many dependencies for the sandbox.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 41f877f3-04d8-44b9-955f-5505c6179b6e
Commits
Reviewing files that changed from the base of the PR and between 4cbfa08 and f057f4d.
Files selected for processing: 2
src/hooks/useTouchEvent.ts
tests/previewTouch.test.tsx
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #538
What
The window
touchmovelistener inuseTouchEventnow callspreventDefault()only whene.cancelableistrue.Why
The preview opens while a touch-scroll gesture is sometimes still in progress. The remaining
touchmoveevents in that gesture are not cancelable, so Chrome ignorespreventDefault()and logs one intervention per event:Behaviour is unchanged: a non-cancelable event can't be prevented, and cancelable events are still blocked from scrolling the page.
Tests
tests/previewTouch.test.tsxSummary by CodeRabbit